﻿Imports Microsoft.VisualBasic
Imports nce.adosql
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Configuration
Imports System.Net.Mail
Partial Class fixclaim
    Inherits Functions

    Public RS As Object ' ADODB.Recordset
    Public strGrey As Object
    Public rowNumber As Integer
    Public subDo As String
    Public vehicleID As Object
    Public __date As Object ' System.Object
    Public cGarageID As Object ' System.Object
    Public claimStatus As Object
    Public garageID As Object
    Public garage As Object ' System.Object
    Public fax As Object ' System.Object
    Public note As Object ' System.Object
    Public areaCode As Object ' System.Object
    Public telephone As Object ' System.Object
    Public email As Object ' System.Object
    Public countryCode As Object ' System.Object
    Public countryCurrency As Object ' System.Object
    Public street As Object ' System.Object
    Public zipcode As Object ' System.Object
    Public city As Object ' System.Object
    Public claimMomentID As Object ' System.Object
    Public claimMoment As Object
    Public costPerHour As Object
    Public numberOfHours As Object
    Public authorisedCostPerHour As Object
    Public authorisedNumberOfHours As Object
    Public claimPartID As Object ' System.Object
    Public claimPart As Object
    Public costPerPart As Object
    Public numberOfParts As Object
    Public authorisedCostPerPart As Object
    Public authorisedNumberOfParts As Object
    Public claimServiceID As Object ' System.Object
    Public claimService As Object
    Public costPerService As Object
    Public numberOfService As Object
    Public authorisedCostPerService As Object
    Public authorisedNumberOfService As Object
    Public amount As Object ' System.Object
    Public authorisedAmount As Object ' System.Object
    Public claimAmount As Object
    Public authorisedClaimAmount As Object
    Public claimMomentAmount As Double
    Public authorisedClaimMomentAmount As Double
    Public claimPartAmount As Double
    Public authorisedClaimPartAmount As Double
    Public claimServiceAmount As Double
    Public authorisedClaimServiceAmount As Double
    Public claimID As Object
    Public insurer As Object
    Public contactPerson As Object
    Public contactPersonEmail As Object
    Public claimReason As Object
    Public claimDecision As Object
    Public consumptionMaterialAmount As Object
    Public authorizedConsumptionMaterialAmount As Object
    Public paymentDate As Object
    Public paymentAmount As Object
    Public mailContent As String
    Public mailSubject As String
    Public regnr As Object ' System.Object

    Public currentDistance As Object
    Public internalDocumentation As Object
    Public claimMomentCount As Object
    Public claimServiceCount As Object
    Public claimPartCount As Object
    Public newInputClaimMoment As Integer
    Public newInputClaimPart As Integer
    Public newInputClaimService As Integer
    Public brand As Object ' System.Object
    Public model As Object ' System.Object
    Public garageInvoiceID As Object
    Public claimDecisionDate As Date
    Public userID As Object ' System.Object
    Public authorizedAmount As Object
    Public requestedAmount As Object
    Protected Overrides Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        dbOpen()

    
        RS = Conn.Execute(" Select claimID,claimDecisionSendDate FROM   tblClaim  WHERE claimDecisionSendDate >= '2011-02-28' and claimDecisionSendDate <='2011-02-28 10:18' order by claimDecisionSendDate")
        If Not RS.EOF Then
            Do Until RS.EOF
                claimID = RS.Fields("claimID").Value
                claimID = CLng(claimID)

                dbOpen()
                RecSet = Conn.Execute("Select c.contactPerson, c.contactPersonEmail, co.countryCode, v.vehicleID, v.regnr, g.garageID, g.email, g.garage From (((tblClaim c INNER JOIN tblCountry co ON co.countryID = c.countryID) INNER JOIN tblVehicle v ON v.vehicleID = c.vehicleID) INNER JOIN tblGarage g ON g.garageID = c.garageID) Where c.claimID = " & claimID & "")
                If RecSet.EOF Then
                    Response.Redirect("editClaim.asp?claimID=" & claimID & "")
                Else
                    contactPerson = RecSet.Fields("contactPerson").Value
                    contactPersonEmail = RecSet.Fields("contactPersonEmail").Value
                    countryCode = RecSet.Fields("countryCode").Value
                    vehicleID = RecSet.Fields("vehicleID").Value
                    regnr = RecSet.Fields("regnr").Value
                    garageID = RecSet.Fields("garageID").Value
                    email = RecSet.Fields("email").Value
                    garage = RecSet.Fields("garage").Value
                End If
                RecSet.Close()
                RecSet = Nothing
                dbClose()
                If countryCode = "FI" Then
                    mailSubject = "" & regnr & " kuluraportti"
                    mailContent = "Hei " & contactPerson & ",<br><br>Lukekaa vastaus kuluraporttiin alla olevasta linkistä:<br><br><a href='http://fls.fragus.se/costAnswer.asp?claimID=" & claimID & "&vehicleID=" & vehicleID & "'>http://fls.fragus.se/costAnswer.asp?claimID=" & claimID & "&vehicleID=" & vehicleID & "</a><br><br>Ellei linkki toimi, voitte kopioida alla olevan osoitteen ja liittää sen Web-selausohjelman osoitekenttään.<br><br>http://fls.fragus.se/costAnswer.asp?claimID=" & claimID & "&vehicleID=" & vehicleID & "<br><br>Ystävällisin terveisin<br><br>Fragus Warranty Finland Oy"
                Else
                    mailSubject = "" & regnr & ""
                    mailContent = ""
                End If
                mailfrom = New MailAddress("claims@fragus." & LCase(countryCode) & "")

                If Len(contactPersonEmail) > 0 Then
                    mailto = New MailAddress(contactPersonEmail)
                Else
                    mailto = New MailAddress(email)

                End If
                myMail = New MailMessage(mailfrom, mailto)
                myMail.Subject = mailSubject
                myMail.IsBodyHtml = True
                myMail.Body = mailContent

                SendmailMailMessage(myMail)
                '  dbOpen()
                ' Conn.Execute("Update tblClaim Set claimDecisionSendDateUserID = " & fragusLeasingUserID & ", claimDecisionSendDate = getDate() Where claimID = " & claimID & "")
                '  dbClose()
                ' Response.Redirect("editClaim.aspx?do=sendClaimAnswerFinished&claimID=" & claimID & "")
                RS.MoveNext()
            Loop
        End If
        RS.Close()
        RS = Nothing
    End Sub
End Class
